<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<link rel="stylesheet" href="${base}/static/media/css/bootstrap.css" />
	<script src="${base}/static/index/vendor/jquery/jquery.min.js"></script>
	<script src="${base}/static/index/vendor/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${base }/static/vendor/bootstrapPager/bootstrapPager.js"></script>
    <script type="text/javascript" charset="utf-8" src="${base }/static/js/My97DatePicker/WdatePicker.js"></script>
    
</head>
<body style="font-size:11px;">
<section id="content">
				
<div class="portlet-body">
    <form class="dataform" id="orderlist_form">
    <div class="row">         
        <label style="width:5%;height: 30px;text-align: right;display: inline-block;">大客户：</label>
        <div style="width:20%;height: 30px;display: inline-block;">
            <select name="businessId" id="business" class="form-control">
            	<option value="">请选择客户</option>
	            <c:forEach items="${Business }" var="business">
				<option value="${business.id }">${business.nickname }</option>
	            </c:forEach>
			</select>
        </div>
        <!-- <label style="width:5%;height: 30px;text-align: right;display: inline-block;">订单编号：</label>
        <div style="width:20%;height: 30px;display: inline-block;" id="order">
            <input type="text" class="form-control" id="orderNo" name="orderNo" value="">
        </div> -->
        <label style="width:6%;height: 30px;text-align: right;display: inline-block;margin-left:2%;">消费时间：</label>	
			<div style="width:10%;height: 30px;display: inline-block;">
				<input class="form-control" value="" name="beginTime" onclick="WdatePicker()" placeholder="开始时间" type="text">
			</div>-
			
			<div style="width:10%;height: 30px;display: inline-block;">
				<input class="form-control" value="" name="endTime" onclick="WdatePicker()" placeholder="结束时间" type="text">
			</div>
    </div>
    <div class="row">
        <div class="btn-group btn-group-sm btn-group-solid" style="float: right;">
            <a  href="javascript:;" onclick="exportOrder()" class="btn offline_serch_hide" style="margin-right:30px;background: #852B99;color:#fff;border-color:#852B99;"><i class="fa fa-search"></i>导出订单</a>
        </div> 
        <div class="btn-group btn-group-sm btn-group-solid" style="float: right;">
            <a  href="javascript:;" onclick="orderlist()" class="btn offline_serch_hide" style="margin-right:30px;background: #18BC9C;color:#fff;border-color:#18BC9C;"><i class="fa fa-search"></i>提交查询</a>
        </div>  
    </div>
    <div style="width: 100%;height: 10px;" ></div>

    <div class="table-scrollable">                         
        <table  class="table table-striped table-bordered table-hover" data-search="true">
            <thead>
                <tr> 
                    <th class="text-center">订单编号</th>
                    <th class="text-center">油卡卡号</th>
                    <th class="text-center">姓名</th>
                    <th class="text-center">电话</th>
                    <th class="text-center">商品名称</th>
                    <th class="text-center">面额</th>
                    <th class="text-center">时间</th>
                    <th class="text-center">订单状态</th>
                </tr> 
            </thead>
            <tbody id="ordercontent"></tbody>
        </table>
        <!-- 分页开始 -->    
		<ul id="page" class="pagination"></ul>
		<input type="hidden" id="pageNum" name="pageNum" value="1">
		<input type="hidden" id="pageSize" name="pageSize" value="10">
		<!-- 分页结束 -->
    </div>
	</form>
</div>
</section>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/layer/layer.js"></script>
<script type="text/javascript">
	function orderlist(pageNum){
		
		$("#pageNum").val(pageNum)
		var data = $("#orderlist_form").serializeArray();
		var businessId = $("#business").val();
		var orderNo = $("#orderNo").val();
		if(businessId == '' & orderNo == ''){
			return;
		}
		$("#ordercontent").html("")
		$.ajax({
        	url:"${base}/admin/order/business/get",
            type:'post',
            dataType:'json',
            data:data,
            success:function(res)
            {
                $.each(res.data.list, function(i, obj) {  
                	var a = obj;
				    var tr = $('<tr>'); 
                    tr.append('<td class="text-center">'+obj.orderNo+'</td>');
                    tr.append('<td class="text-center">'+obj.gascardNo+'</td>');
                    tr.append('<td class="text-center">'+obj.fillName+'</td>');
                    tr.append('<td class="text-center">'+obj.telephone+'</td>');
                    tr.append('<td class="text-center">'+obj.bmItemName+'</td>');
                    tr.append('<td class="text-center">'+obj.facePrice+'</td>');
                    tr.append('<td class="text-center">'+obj.orderTime+'</td>');
                    
                    var state = obj.rechargeState;
                    if(state == '0'){
                    	state = '充值中';
                    }else if(state =='1'){
                    	state = '成功';
                    }else if(state == '9'){
                    	state = '撤销';
                    }
                 	tr.append('<td class="text-center">'+state+'</td>');
                 	
                    //订单内容 tbody
                    $("#ordercontent").append(tr);
				});
				var total = res.data.total; // 总条数
				var pages = res.data.pages; // 总页数
				var pageNum = res.data.pageNum; // 当前页
				var pageSize = res.data.pageSize; // 每页显示条数
				
				$("#page").html('').append(Pager({
				    totalCount:total, 		//总条数为150
				    pageSize: pageSize,    			//每页显示6条内容，默认10
				    buttonSize: 5,   		//显示6个按钮，默认10
				    pageNum: pageNum,   		//页码的参数名为'p'，默认为'page'
				    prevButton:'上一页',     //上一页按钮
				    nextButton:'下一页',     //下一页按钮
				    firstButton:'首页',      //第一页按钮
				    lastButton:'末页',       //最后一页按钮

				}));
            }
        });
        return false;
	}
	
	function exportOrder() {
		var businessId = $("#business").val();
		var orderNo = $("#orderNo").val();
		if(businessId == '' & orderNo == ''){
			return;
		}
		var a = document.createElement('a');
		var data = $("#orderlist_form").serialize();
		debugger;
		var url = '${pageContext.request.contextPath}/admin/order/business/export?'+ data;
		a.href=url;
		a.click();
	}
	
	
</script>


</body>
</html>